
import { Message,Wechaty as WechatyType } from "_wechaty@0.60.12@wechaty";
import { config } from "./config/config";

export async function onMessage(this:WechatyType, msg:Message){
    if(msg.self())return
    const isRoom = msg.room()
    if(isRoom) return

    const text = msg.text()
    if(+text === 1 || text ==='拉我进群'){
        const room = await this.Room.find({
            topic: config.inviteRoom[0]
        })
        return room?.add(msg.talker())
    }

    // 收到消息为菜单
    if (text === '菜单') {
        return msg.say(config.template)
      }
}